import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Switch } from 'ant-design-vue';
import { setRoleStatus } from '/@/api/demo/system';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { defHttp } from '/@/utils/http/axios';
enum Api {
  PageList = '/sys/sysLog/listByPage',
  Add = '/sys/sysLog/add',
  Edit = '/sys/sysLog/edit',
  Delete = '/sys/sysLog/delete?id=',
}
const { t } = useI18n();
//
export const getListByPage = (params?: any) => defHttp.get<any>({ url: Api.PageList, params });
//
export const addSysLog = (params?: any) => {
  return defHttp.post<any>({ url: Api.Add, params });
};

export const editSysLog = (params?: any) => {
  return defHttp.put<any>({ url: Api.Edit, params });
};

/**
 * 删除字典
 */
export const deleteSysLog = (id, handleSuccess) => {
  return defHttp.delete({ url: Api.Delete + id }).then(() => {
    handleSuccess();
  });
};

export const columns: BasicColumn[] = [
  {
    title: '日志内容',
    dataIndex: 'logContent',
    width: 200,
  },
  {
    title: 'IP',
    dataIndex: 'ip',
    width: 200,
  },
  {
    title: '请求java方法',
    dataIndex: 'method',
    width: 200,
  },
  {
    title: '请求路径',
    dataIndex: 'requestUrl',
    width: 200,
  },
  {
    title: '请求参数',
    dataIndex: 'requestParam',
    width: 200,
  },
  {
    title: '耗时',
    dataIndex: 'costTime',
    width: 200,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'ip',
    label: 'IP',
    component: 'Input',
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: '',
    required: true,
    component: 'Input',
  },
  {
    field: 'logType',
    label: '日志类型（1登录日志，2操作日志）',
    required: true,
    component: 'Input',
  },
  {
    field: 'logContent',
    label: '日志内容',
    required: true,
    component: 'Input',
  },
  {
    field: 'operateType',
    label: '操作类型',
    required: true,
    component: 'Input',
  },
  {
    field: 'userid',
    label: '操作用户账号',
    required: true,
    component: 'Input',
  },
  {
    field: 'username',
    label: '操作用户名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'ip',
    label: 'IP',
    required: true,
    component: 'Input',
  },
  {
    field: 'method',
    label: '请求java方法',
    required: true,
    component: 'Input',
  },
  {
    field: 'requestUrl',
    label: '请求路径',
    required: true,
    component: 'Input',
  },
  {
    field: 'requestParam',
    label: '请求参数',
    required: true,
    component: 'Input',
  },
  {
    field: 'requestType',
    label: '请求类型',
    required: true,
    component: 'Input',
  },
  {
    field: 'costTime',
    label: '耗时',
    required: true,
    component: 'Input',
  },
  {
    field: 'createBy',
    label: '创建人',
    required: true,
    component: 'Input',
  },
  {
    field: 'createTime',
    label: '创建时间',
    required: true,
    component: 'Input',
  },
  {
    field: 'updateBy',
    label: '更新人',
    required: true,
    component: 'Input',
  },
  {
    field: 'updateTime',
    label: '更新时间',
    required: true,
    component: 'Input',
  },
];
